{ "cells": [ { "cell_type": "markdown", "id": "48b0046a", "metadata": {}, "source": [ "# Quick Start: Hello, World!" ] }, { "cell_type": "code", "execution_count": 1, "id": "5b1e03fc", "metadata": {}, "outputs": [], "source": [ "# update your agent information, and then connect to it\n", "from ia.gaius.agent_client import AgentClient\n", "\n", "api_key = ''\n", "name = ''\n", "domain = 'localhost'\n", "secure = True\n", "\n", "agent_info = {'api_key': api_key,\n", " 'name': name,\n", " 'domain': domain,\n", " 'secure': secure}\n", "\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "7c6d5396", "metadata": {}, "outputs": [], "source": [ "agent_info = {'api_key': 'ABCD-1234',\n", " 'name': '',\n", " 'domain': 'gaius-api:80',\n", " 'secure': False}" ] }, { "cell_type": "code", "execution_count": 3, "id": "c764156b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'connection': 'okay', 'agent': 'simple'}" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent = AgentClient(agent_info, verify=False)\n", "agent.connect()" ] }, { "cell_type": "code", "execution_count": 4, "id": "17bcdad0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'id': 'p46b6b076c', 'name': 'P1'}]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Let's use only one node\n", "ingress_nodes = ['P1']\n", "query_nodes = ['P1']\n", "\n", "agent.set_ingress_nodes(ingress_nodes)\n", "agent.set_query_nodes(query_nodes)" ] }, { "cell_type": "markdown", "id": "ba485d71", "metadata": {}, "source": [ "## Four API Calls" ] }, { "cell_type": "code", "execution_count": 5, "id": "5091b0d6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'wm-cleared'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# clear working memory\n", "agent.clear_wm(nodes=ingress_nodes)\n", "# agent.clear_wm()" ] }, { "cell_type": "code", "execution_count": 6, "id": "2cb3863c", "metadata": {}, "outputs": [], "source": [ "sequence_1 = [{\"strings\": [\"hello\"], \"vectors\": [], \"emotives\": {}}, \n", " {\"strings\": [\"world\"], \"vectors\": [], \"emotives\": {}}]\n", "\n", "# Observe a sequence of events\n", "for event in sequence_1:\n", " agent.observe(data=event,nodes=ingress_nodes)" ] }, { "cell_type": "code", "execution_count": 7, "id": "cd7f52ed", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'MODEL|7d0678ba6305341ce0d25133ab086208656a562f'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Learn a sequence\n", "agent.learn(nodes=ingress_nodes)" ] }, { "cell_type": "code", "execution_count": 8, "id": "184083db", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'observed'" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Observe new data\n", "agent.observe(data={\"strings\": [\"hello\"], \"vectors\": [], \"emotives\": {}},nodes=ingress_nodes)" ] }, { "cell_type": "code", "execution_count": 9, "id": "6fcb8bbb", "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "[{'confidence': 1,\n", " 'confluence': 0.5,\n", " 'emotives': {},\n", " 'entropy': 0.5,\n", " 'evidence': 0.5,\n", " 'extras': [],\n", " 'fragmentation': 0,\n", " 'frequency': 5,\n", " 'future': [['world']],\n", " 'grand_hamiltonian': 0.5,\n", " 'hamiltonian': 0,\n", " 'itfdf_similarity': 1,\n", " 'matches': ['hello'],\n", " 'missing': [],\n", " 'name': '7d0678ba6305341ce0d25133ab086208656a562f',\n", " 'past': [],\n", " 'potential': 3.5,\n", " 'present': [['hello']],\n", " 'similarity': 0.666666687,\n", " 'snr': 1,\n", " 'type': 'prototypical'}]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Get Predictions\n", "agent.get_predictions()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 5 }